package com.byq.mm.application.cluster.client;

import com.byq.mm.abstractx.device.Device;
import com.byq.mm.abstractx.engine.CoreEnvironment;
import com.byq.mm.application.cluster.datatype.SimpleLocation;
import com.byq.mm.application.cluster.provider.LocationProvider;
import com.byq.mm.foundation.cluster.client.BasicClusterClient;
import com.byq.mm.foundation.cluster.datatype.AttributeValue;

import java.util.ArrayList;



public class LocationClient extends BasicClusterClient {

	public LocationClient(String cluster, Device device, CoreEnvironment e) {
		super(cluster, device, e);
		
	}
	public SimpleLocation getLocation(){
		return (SimpleLocation)getAttributeValue(LocationProvider.Define.Attributes.LOCATION);
	}
	public void locate() {
		readAttribute(LocationProvider.Define.Attributes.LOCATION);

	}

	@Override
	protected Class<? extends AttributeValue> getAttributeType(String attributeName) {
		if(attributeName.equals(LocationProvider.Define.Attributes.LOCATION))
			return SimpleLocation.class;
		return null;
	}
	public void subscribe() {
		subscribe(LocationProvider.Define.Attributes.LOCATION);

	}
	public void unsubscribe() {
		unsubscribe(LocationProvider.Define.Attributes.LOCATION);
	}
	public boolean isSubscribed() {
		return subscribed.get(LocationProvider.Define.Attributes.LOCATION);
	}
	public void readSubscribe() {
		readSubscribe(LocationProvider.Define.Attributes.LOCATION);
	}
	@Override
	protected void init() {
		attributes.put(LocationProvider.Define.Attributes.LOCATION,new SimpleLocation());
		subscribed.put(LocationProvider.Define.Attributes.LOCATION,  false);
		
	}



}
